package org.tis.tools.abf.module.jnl.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.tis.tools.abf.module.jnl.feign.ILogDataAbfFeignService;
import org.tis.tools.model.common.ResultVO;
import org.tis.tools.model.log.LogData;
import org.tis.tools.starter.mybatisplus.querykit.model.Query;

import javax.validation.constraints.NotBlank;

/**
 * Created by chenchao
 * Created on 2018/9/1 13:50
 */
@RestController
@RequestMapping("/logData")
@Validated
public class LogDataController {

    @Autowired
    private ILogDataAbfFeignService logDataAbfFeignService;

    @ApiOperation(value = "根据操作日志ID分页查询操作数据记录",notes = "传入分页数据,操作日志ID(guidOperate)作为参数")
    @PostMapping("/listByOperateId")
    public ResultVO list(@RequestBody @Validated Query<LogData> query ) {
        return  logDataAbfFeignService.listByOperateId(query);
    }

    @ApiOperation(value = "根据GUID查询操作数据记录",notes = "传入操作数据记录的guid作为参数")
    @GetMapping("/{id}")
    public ResultVO detial(@PathVariable @NotBlank(message = "id不能为空") String id){

        return ResultVO.success("查询成功",logDataAbfFeignService.detial(id));
    }

    @ApiOperation(value = "根据数据GUID查询操作数据记录",notes = "传入分页数据,数据GUID(dataGuid)作为参数")
    @PostMapping("/list")
    public ResultVO listByDataId(@RequestBody @Validated Query<LogData> query ){
        return logDataAbfFeignService.list(query);
    }
}
